﻿#ifndef HNRJITIMAGING_H
#define HNRJITIMAGING_H

#include "HnrjitWigdet.h"

interface IImage;
interface IImagingFactory;

template class CAtlArray<TCHAR>;

class DIRECTUI_API CHnrjitImaging
{
public:
	/// <summary>初始化COM组件</summary>
	static BOOL ImagingInitialize();

	/// <summary>反初始化COM组件</summary>
	static BOOL ImagingUninitialize();

	/// <summary>获取应用程序目录</summary>
	static const TCHAR* AppDirPath();

	/// <summary>UTF8转UTF16或GBK</summary>
	/// <param name="localStr">UTF8字符串</param>
	/// <param name="result">UTF16或GBK字符串</param>
	/// <returns><see name="result /></returns>
	static const TCHAR* Utf8ToLocal(const CHAR* pszUtf8Str, CAtlArray<TCHAR>* paResult);

	/// <summary>UTF16或GBK转UTF8</summary>
	/// <param name="localStr">UTF16或GBK字符串</param>
	/// <param name="result">UTF8字符串</param>
	/// <returns><see name="result /></returns>
	static const CHAR* LocalToUtf8(const TCHAR* pszLocalStr, CAtlArray<CHAR>* paResult);

	/// <summary>加载PNG,JPG或GIF格式文件</summary>
	/// <param name="pszFilePath">图片文件路径</param>
	/// <param name="hZipRes">ZIP资源句柄</param>
	/// <returns>已加载的IImage对象</returns>
	static CComPtr<IImage> LoadFromFile(const TCHAR* pszFilePath, HZIP hZipRes = NULL);

	/// <summary>通过IImage创建HBITMAP对象</summary>
	/// <param name="spImage">源图像IImage对象</param>
	/// <param name="bmpSize">目标HBITMAP大小</param>
	/// <returns>已创建的HBITMAP对象</returns>
	static HBITMAP CreateHBitmap(CComPtr<IImage> spImage, const SIZE& bmpSize);
};

#endif // HNRJITIMAGING_H